
<%@page import="ejb.RecensioneEsterna"%>
<%@page import="ejb.Videogame"%>
<%@page import="ejb.RecensioneInterna"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%@page import="java.util.LinkedList"%>
<%@page import="java.util.List"%>
<%@page import="ejb.Utente"%>
<%@page import="ejb.ArticoloNuovo"%>
<%@page import="ejb.ArticoloUsato"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>


<%@include file="wrapper.jsp" %>
<%
    String tipo = "uv";
    if (session.getAttribute("utente") != null) {
        Utente utSession = (Utente) session.getAttribute("utente");
        tipo = utSession.getTipo();
    }

%>
<div class="container">
    <div class="row-fluid">
        <div class="span3 bs-docs-sidebar">
            <ul class="nav nav-list bs-docs-sidenav">
                <% if (request.getParameter("platform") != null) {%>
                <li><a href="Controller?button=visualizzaRecNot&platform=<%=request.getParameter("platform")%>&type=news"> <button class="btn btn-large btn-inverse btn-block" type="button"><i class="icon-white icon-th-list"></i> Notizie</button> </a></li>
                <li><a href="Controller?button=visualizzaRecNot&platform=<%=request.getParameter("platform")%>&type=reviews"><button class="btn btn-large btn-inverse btn-block" type="button"><i class="icon-white icon-th-list"></i> Recensioni</button> </a></li>
                <li><a href="Controller?button=visualizzaRecNot&platform=<%=request.getParameter("platform")%>&type=both"><button class="btn btn-large btn-inverse btn-block" type="button"><i class="icon-white icon-th-list"></i> Entrambe</button> </a></li>
                <%} else {%>
                <li><a href="Controller?button=visualizzaRecNot&platform=all&type=news"> <button class="btn btn-large btn-inverse btn-block" type="button"><i class="icon-white icon-th-list"></i> Notizie</button> </a></li>
                <li><a href="Controller?button=visualizzaRecNot&platform=all&type=reviews"><button class="btn btn-large btn-inverse btn-block" type="button"><i class="icon-white icon-th-list"></i> Recensioni</button> </a></li>
                <li><a href="Controller?button=visualizzaRecNot&platform=all&type=both"><button class="btn btn-large btn-inverse btn-block" type="button"><i class="icon-white icon-th-list"></i> Entrambe</button> </a></li>
                <%}%>
            </ul>
        </div>
        <div class="span6">

            <%
                LinkedList<ArticoloNuovo> carrello = (LinkedList<ArticoloNuovo>) session.getAttribute("carrello");
                Integer totCarrello = 0;
                List<ArticoloUsato> usatiDaConfermare = (List<ArticoloUsato>) session.getAttribute("usatiDaConfermare");

                RecensioneInterna recensione = (RecensioneInterna) request.getAttribute("RecensioneSelezionata");
                String testo = (String) request.getAttribute("testo");
                DateFormat dataFormat = new SimpleDateFormat("dd-MM-yyyy");
                String data = dataFormat.format(recensione.getData());
                List<RecensioneEsterna> re = (List<RecensioneEsterna>) request.getAttribute("RecensioniEsterne");
                double media=0;
                if (re!=null){
                    for (RecensioneEsterna q :re) media+=q.getVoto().getValutazione()*10/q.getVoto().getScala(); 
                    media/=re.size();
                }
                double valutazione=recensione.getVideogiochi().get(0).getVoto().getValutazione();
                
            %>
            <div class="thumbnail">
                   
                <h3 style="padding-left:10px"><%=recensione.getTitolo()%></h3>

                <p style="padding-left:10px;"> di <em style="font-family: italic"> <%=recensione.getAutore().getNome() + " " + recensione.getAutore().getCognome()%></em></p>
                <p><b style="padding-left:10px">Inserito il:</b> <%=data%></p>
                
                <span class="thumbnail" style="width: 125px;height: 100px">
                    <label style="padding-top: 0px;text-align: center; font-size: medium">Voto</label>
                   
                <div style="line-height: 50px; display: inline-block; background-color:purple; color:white; font-size:30px; text-align: center; width:50px;height: 50px;  margin-left: 10px; "><%= valutazione %> </div>
                <div style="line-height: 50px; display: inline-block; background-color:gray; color:white; text-align: center;font-size:30px;  width:50px;height: 50px;  "><%= media %> </div>
             </span>
                <img src="<%=recensione.getImmagini().get(0)%>"  align="left" style="padding-left:10px;padding-top:5px;height: 200px;width: 400px"/>   
          
                <br><br><br><br><br><br><br><br><br><br><br><br>
                <%
                    if (recensione.getImmagini().size() > 1){
                        for (int k = 1; k < recensione.getImmagini().size(); k++) {%>
                        <img src="<%=recensione.getImmagini().get(k)%>"  align="left" style="padding-left:10px;padding-top:5px;height: 100px;width: 100px"/>   
                
                <%} %><br><br><br><br><br><br><br><br>
 <%} %>



                <ul style="margin-left:10px"><h5>Pro:</h5>
                    <% for (String p : recensione.getPro()) {%>
                    <li style="margin-left:50px"> <%=p%>  </li>
                    <%}%>

                </ul>
                <br>
                <ul style="margin-left:10px"><h5>Contro:</h5>
                    <% for (String p : recensione.getContro()) {%>
                    <li style="margin-left:50px"> <%=p%>  </li>
                    <%}%>

                </ul>

                <p align="JUSTIFY" style="margin-top: 30px;margin-left:10px; margin-right: 10px" name="testo" ><%=testo%></p>
                <hr>
                <br>
                <ul style="margin-left:10px;margin-bottom: 10px;list-style-type: none;font-size: 16px">Link Esterni:
                    <div style="padding-top:10px"></div>
                    <%if (re != null) {
                            for (RecensioneEsterna r : re) {%> 
                    <a href="<%=r.getUrl()%>" target=”_blank”  > <li style="color: #4F4F4F;font-size: 14px ;text-decoration: none ;text-decoration-color: #4F4F4F; " ><%=r.getUrl()%></li> </a> 

                    <%}
                        }%>
                </ul>
                <% for (Videogame v : recensione.getVideogiochi()) {%>
                <p style="margin-left:10px"><b> <a href="Controller?button=visualizzaVideogioco&amp;id=<%=v.getId()%>"><%=v.getNomeEPiattaforma()%> - Scheda Videogioco</a></b></p>
                <%}%>

                

            </div>


        </div>
        <div class="span3">
            <%
                if (tipo.equals("u")) {
            %>
            <div class="thumbnail">
                <p><b>Carrello</b></p>
                <table>
                    <tr><td></td><td style="padding-left: 5px"><b>Articolo</b></td><td style="padding-left: 5px"><b>Costo</b></td></tr>
                    <tr><td><br></td><td><br></td><td><br></td></tr>
                            <%
                                for (ArticoloNuovo a : carrello) {
                                    totCarrello = totCarrello + a.getPrezzo();
                            %>
                    <tr>
                    <p>
                    <td>
                        <a href="Controller?button=removeCarrello&amp;idArticolo=<%=a.getId()%>">
                            <button class="btn btn-inverse btn-mini"><i class="icon-white icon-trash"></i></button>
                        </a>
                    </td>
                    <td style="padding-left: 5px;height: 20px;width:100%;overflow:hidden;float:left"><%=a.getNome()%></td>
                    <td style="padding-left: 5px"><%=a.getPrezzo().toString()%> €</td>
                    </p>
                    </tr>
                    <tr><td><br></td><td><br></td><td><br></td></tr>
                            <%}%>
                    <tr><td></td><td><b>Totale</b></td><td style="padding-left: 5px"><%=totCarrello.toString()%> €</td></tr>
                </table>
            </div>
            <br>
            <br>
            <%} else if (tipo.equals("a")) {%>
            <div class="thumbnail">
                <p><b>Notes</b></p>
                <br>
                <% if (!usatiDaConfermare.isEmpty()) {%>
                <p> Ancora <%=usatiDaConfermare.size()%> articoli da confermare </p>
                <br>
                <p align="center">
                    <a href="Controller?button=modificaCancellaArtUsati&amp;confirm=s">
                        <button class="btn btn-inverse btn-small"><i class="icon-white icon-th-list"></i> Vedi Articoli da confermare</button>
                    </a>
                </p>
                <%} else {%>
                <p> Nessun articolo da confermare </p>
                <%}%>      
            </div>
            <br>
            <br>
            <%}%>

            <form  class="navbar-search" action="Controller"> <input type="text" name="cerca" class="search-query span3" style="width:220px;" placeholder="Cerca"><div class="icon-search" ></div></form>
        </div> 
    </div>           
</div>
</body>
</html>



